package com.jy.rhin.infra.cda.mzzy;

import com.jy.framework.base.utils.Converter;
import com.jy.rhin.model.CodeObject;
import com.jy.rhin.model.ValueUnit;
import com.jy.rhin.model.body.yongyao.YongYao;
import com.jy.rhin.utils.CDAUtil;
import lombok.Data;
import org.apache.commons.lang.time.DateUtils;

import java.math.BigDecimal;
import java.util.Date;

/**
 * @author dhl
 * @date 2023/2/15
 * @Description
 */
@Data
public class ZhongYaoInfoVo {
    public YongYao.YongYaoItem menZhenZhongYaoVo() {
        YongYao.YongYaoItem yongYaoItem = new YongYao.YongYaoItem();
        yongYaoItem.setYongYaoTJ(new CodeObject(this.yongYaoTJDM, this.yongYaoTJMC));
        yongYaoItem.setDanCiYYJL(new ValueUnit(Converter.toString(new BigDecimal(this.yaoWuSYCJL).setScale(2, BigDecimal.ROUND_HALF_UP)), this.yaoWuSYJLDWMC));
        yongYaoItem.setYaoWuSYPL(new ValueUnit(Converter.toString(this.meiRiTS), "帖/日"));
        yongYaoItem.setYaoWuJX(new CodeObject(this.yaoPinJXDM, this.yaoPinJXMC.replace("其它", "其他").replace("）", ")")));
        yongYaoItem.setYaoPinMC(this.zhongYaoMC);
        yongYaoItem.setYaoWuLX("中药");
        yongYaoItem.setYongYaoTS(new ValueUnit(Converter.toString(this.yongYaoTS, "0"), "d"));
        yongYaoItem.setYaoWuSYZJL(new ValueUnit(Converter.toString(new BigDecimal(this.chuFangTS).multiply(new BigDecimal(this.meiRiTS)).multiply(new BigDecimal(this.yaoWuSYCJL)).setScale(2, BigDecimal.ROUND_HALF_UP)), this.yaoWuSYJLDWMC));
        Date date = DateUtils.addDays(this.chuFangFYRQSJ == null ? this.chuFangKLRQSJ : this.chuFangFYRQSJ, this.yongYaoTS == null ? 0 : this.yongYaoTS);
        yongYaoItem.setYongYaoTZRQ(CDAUtil.toD15(date));
        return yongYaoItem;
    }

    /**
     * 就诊流水号
     */
    private String menZhenJZLSH;
    /**
     * 用药途径代码
     */
    private String yongYaoTJDM;
    private String yongYaoTJMC;
    /**
     * 单次用药剂量
     */
    private String yaoWuSYCJL;
    /**
     * 单次用药剂量单位代码
     */
    private String yaoWuSYJLDWDM;
    private String yaoWuSYJLDWMC;
    /**
     * 药物使用频次描述
     */
    private String shiYongPCMS;
    /**
     * 药品剂型代码
     */
    private String yaoPinJXDM;
    private String yaoPinJXMC;
    /**
     * 中药名称
     */
    private String zhongYaoMC;
    /**
     * 用药天数
     */
    private Integer yongYaoTS;
    private Integer meiRiTS;
    /**
     * 处方帖（剂）数
     */
    private String chuFangTS;
    /**
     * 发药时间
     */
    private Date chuFangFYRQSJ;
    private Date chuFangKLRQSJ;

}
